﻿using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens;
using System.Text;

namespace TestProject1
{
    [TestClass]
    public sealed class Test1
    {
        [TestMethod]
        public void TestMethod1()
        {
            DB.Models.QiAuthBaseContext db = new DB.Models.QiAuthBaseContext();
            var test = db.RegistUsers
                .Include(s=>s.Role)
                .Include(s=>s.Department)
                .Include(s=>s.ThirdPartyEntrances).ToList();
            db.Dispose();
        }

        [TestMethod]
        public void TestMethod2()
        {
            // 正确配置DbContextOptions
            var options = new DbContextOptionsBuilder<DB.Models.QiAuthBaseContext>()
                .UseSqlServer("Data Source=.;Initial Catalog=QiAuthBase;User ID=qi;Password=123456")
                .UseLazyLoadingProxies() // 启用延迟加载
                .Options;

            using (var db = new DB.Models.QiAuthBaseContext(options))
            {
                // 显式加载多层关联数据
                var logs = db.Logs
                    .Include(l => l.RegistUser)
                        .ThenInclude(u => u.Role)  // 加载用户的角色
                    .Include(l => l.RegistUser)
                        .ThenInclude(u => u.Department)  // 加载用户的部门
                    .ToList();
            }
        }

        [TestMethod]
        public void TestMethod3()
        {
            var t1 = DB.Utils.Tools.NewGuid();

            var t2 = DB.Utils.Tools.NewHsha256("123456");

        }
    }
}
